package com.ruoyi.framework.reptile.webmagic.jingcai.football;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * @author dzl
 * @Description 查询竞彩足球比赛结果
 * @date 2024年07月15日 21:04:00
 */
public class JingCaiFootBallResultPageProcessor implements PageProcessor {

    // 部分一：抓取网站的相关配置，包括编码、抓取间隔、重试次数等
    private Site site = Site.me().setRetryTimes(3).setSleepTime(1000);

    @Override
    public Site getSite() {
        return site;
    }

    @Override
    public void process(Page page) {
        String rawText = page.getRawText();
        page.putField("jcData", rawText);
    }

    public static void main(String[] args) {
        Spider.create(new JingCaiFootBallOpeningQuotationProcessor())
                //从"https://github.com/code4craft"开始抓
                .addUrl("https://webapi.sporttery.cn/gateway/jc/football/getMatchResultV1.qry?matchPage=1&matchBeginDate=2024-07-13&matchEndDate=2024-07-15&leagueId=&pageSize=30&pageNo=1&isFix=0")
                .addPipeline(new JingCaiFootBallResultPipeline())
                //开启5个线程抓取
                .thread(5)
                //启动爬虫
                .run();
    }
}
